home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 138
/
Volume 138 Aug 19 2011 - Damaged.iso
/
Games
/
hopes_babysitting_maze.swf
/
scripts
/
__Packages
/
smashing
/
SoundEngine.as
< prev
Wrap
Text File
|
2011-08-19
|
3KB
|
98 lines
class smashing.SoundEngine
{
var DEFAULTMCNAME = "soundEngine_MC";
var DEFAULTGROUPNAME = "sound";
function SoundEngine(t_path, t_depth, t_overwrite)
{
this.mc = t_path.createEmptyMovieClip(this.DEFAULTMCNAME,t_depth);
this.o_sounds = new Object();
this.o_groups = new Object();
if(t_overwrite == undefined)
{
t_overwrite = false;
}
this.flagOverwrite = t_overwrite;
this.groupCount = 0;
this.createGroup(this.DEFAULTGROUPNAME);
trace("-- Init Sound Engine -- ");
}
function createGroup(t_name)
{
this.groupCount = this.groupCount + 1;
var _loc2_ = this.mc.createEmptyMovieClip(t_name,this.groupCount);
_loc2_.soundObject = new Sound(_loc2_);
this.o_groups[t_name] = _loc2_;
}
function createSound(t_name, t_assetID, t_group)
{
var _loc3_ = undefined;
if(t_group == undefined)
{
_loc3_ = this.o_groups[this.DEFAULTGROUPNAME];
}
else
{
_loc3_ = this.o_groups[t_group];
}
if(_loc3_ != undefined)
{
var _loc2_ = {};
_loc2_.soundEffect = new Sound(_loc3_);
_loc2_.soundEffect.attachSound(t_assetID);
this.o_sounds[t_name] = _loc2_;
}
else
{
trace("Error Locating Group " + t_group + " for create Sound");
}
}
function playSound(t_name, t_loops)
{
if(this.muted)
{
return undefined;
}
var _loc3_ = this.o_sounds[t_name];
if(_loc3_ != undefined)
{
if(t_loops == undefined)
{
t_loops = 1;
}
else if(t_loops == 0)
{
t_loops = 1000;
}
if(_global.K_SoundEngine.OverwriteSounds)
{
_loc3_.SoundEffect.stop(_loc3_.idName);
}
_loc3_.soundEffect.start(0,t_loops);
}
else
{
trace("Error - sound " + t_name + " not found");
}
}
function stopSound(t_name)
{
this.o_sounds[t_name].soundEffect.stop();
}
function changeVolume(t_vol, t_groupName)
{
if(t_groupName == undefined)
{
t_groupName = this.DEFAULTGROUPNAME;
}
this.o_groups[t_groupName].soundObject.setVolume(t_vol);
}
function soundOff()
{
this.muted = true;
}
function soundOn()
{
this.muted = false;
}
}